package game.client.net;

import java.io.IOException;
import java.nio.BufferOverflowException;

import game.common.world.Vector;

public class PlayerPositionSender {
	
	private GameConnection connection;
	
	private long minInterval = 500;
	
	private long lastSent = -1;
	
	public PlayerPositionSender(GameConnection connection) {
		this.connection = connection;
	}
	
	public void send(Vector position) throws BufferOverflowException, IOException{
		long now = System.currentTimeMillis();
		
		if (now - lastSent >= minInterval){
			lastSent = System.currentTimeMillis();
			this.connection.sendUpdatePosition(position);
		}
	}
}
